#include <stdio.h>
main()
{
int n,t;while ( scanf("%d", &n) != EOF && n ){
t = 0;
while((n&1)==0)
{n>>= 1;
t++;}
printf("%d\n",1<<t);
}}
